/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mainpackage;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet.*;

/**
 *
 * @author foonwayx
 */
public class InputInterFace extends Form implements ItemCommandListener, CommandListener {

    public Command cmdOk;
    public Command cmdOk1;
    public Command cmdOk2;
    public Command cmdOk3;
    public Command cmdOk4;
//    public Command cmdOkprivate;
    public Command cmdCancel;
    public static TextField commonInput=new TextField("", "", 1, 1),
    commonInput2=new TextField("", "", 1, 1), 
    commonInput3=new TextField("", "", 1, 1), 
    commonInput4=new TextField("", "", 1, 1);
    public Item item;
    public ChoiceGroup choiceGroupPrivate;
    //
    public StringItem button;
    public StringItem name, password, superPassword;
    public Command BUTTON_CMD;
    //
    public byte byGameState;
    public byte byUiState;
    public ChoiceGroup choiceGroupOne;
    public ChoiceGroup choiceGroupTwo;
    public Alert alert;
    public ChoiceGroup options_second;
    public InputInterFace inputInterSmile = null;
    public InputInterFace inputInterTask = null;
    public InputInterFace inputInterItems = null;
    private static InputInterFace sInstance;
    public static InputInterFace getInstance() {
    	if (sInstance == null) {
    		sInstance = new InputInterFace("");
    	}
    	return sInstance;
    }
    
    private InputInterFace(String title) {
    	super(title);
    }
    /**
     * 设置input
     * @param byUiState
     * @param title
     */
    public void setInputInterFace(byte byUiState, String title) {
//    	super(title);
        //#if NOKIA_S60V5
         MainCanvas.clearpointerPressedKey();
        //#endif
        this.byGameState = MainLogic.getInstance().byGameState;
        this.byUiState = byUiState;
        deleteAll();
        switch (this.byGameState) {
            case Constant.GAME_UI_CHANGE_PASSWD:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                name = new StringItem("快速注册用户名：", GameBean.STR_CMD_LOGIN_USENAME);
                password = new StringItem("快速注册密码：", GameBean.STR_CMD_LOGIN_PASSWORD);
                superPassword = new StringItem("快速二级密码：", GameBean.STR_CMD_LOGIN_PASSWORD);
                commonInput.setTextField("请输入新密码：", "", Constant.MAX_USER_PASSWORD_LENGTH, TextField.ANY);
                commonInput2.setTextField("请输入新二级密码：", "", Constant.MAX_USER_PASSWORD_LENGTH, TextField.ANY);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                this.append(name);
                this.append(password);
                this.append(superPassword);
                this.append(commonInput);
                this.append(commonInput2);
                setCommandListener(this);
                break;
            case Constant.GAME_UI_OPTION_LIST:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                commonInput.setTextField("用户名：", "", 13, TextField.ANY);
                commonInput2.setTextField("密码：", "", 13, TextField.PASSWORD);
                commonInput3.setTextField("确认密码：", "", 13, TextField.PASSWORD);
                commonInput4.setTextField("二级密码：（找回密码用）", "", 13, TextField.PASSWORD);
                this.append(commonInput);
                this.append(commonInput2);
                this.append(commonInput3);
                this.append(commonInput4);
                break;
            case Constant.GAME_UI_LOGIN:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                commonInput.setTextField("用户名：", MainLogic.getInstance().uiLogin.sArray[0] == null ? "" : MainLogic.getInstance().uiLogin.sArray[0], Constant.MAX_USER_NAME_LENGTH, TextField.ANY);
                commonInput2.setTextField("密码：", MainLogic.getInstance().uiLogin.sArray[1] == null ? "" : MainLogic.getInstance().uiLogin.sArray[1], Constant.MAX_USER_PASSWORD_LENGTH, TextField.PASSWORD);
                this.append(commonInput);
                this.append(commonInput2);
                break;
            case Constant.GAME_UI_CREATE_ROLE:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                if (this.byUiState == 4) {
                    commonInput.setTextField("姓名：", GameBean.STR_CMD_PLAYER_NICK, Constant.MAX_ROLE_NAME_LENGTH, TextField.ANY);
                    this.append(commonInput);
                }
                break;
            case Constant.GAME_UI_CHAT:
                this.cmdOk = new Command("发送", Command.OK, 1);
//                this.cmdOk1 = new Command("表情", Command.OK, 1);
//                this.cmdOk2 = new Command("物品", Command.OK, 1);
//                this.cmdOk3 = new Command("任务", Command.OK, 1);
                this.cmdOk4 = new Command("重复", Command.OK, 1);
                this.cmdCancel = new Command("返回", Command.CANCEL, 1);
                this.addCommand(cmdOk);
//                this.addCommand(cmdOk1);
//                this.addCommand(cmdOk2);
//                this.addCommand(cmdOk3);
                this.addCommand(cmdOk4);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                commonInput.setTextField("内容：(少于30字)", MainLogic.getInstance().uiEquipment.sStrArray[0], 30, TextField.ANY);
                this.append(commonInput);
                switch (MainLogic.getInstance().uiEquipment.chatshoutType) {
                    case 0:

                        break;
                    case 1:
                        String[] optionStrings_1 = {"世界"};
                        ChoiceGroup options_1 = new ChoiceGroup("频道", Choice.EXCLUSIVE, optionStrings_1, null);
                        this.append(options_1);
                        break;
                    case 2:
                        String[] optionStrings_2 = {"区域"};
                        ChoiceGroup options_2 = new ChoiceGroup("频道", Choice.EXCLUSIVE, optionStrings_2, null);
                        this.append(options_2);
                        break;
                    case 3:
                        String[] optionStrings_3 = {"私聊"};
                        ChoiceGroup options_3 = new ChoiceGroup("频道", Choice.EXCLUSIVE, optionStrings_3, null);
                        this.append(options_3);
//                        String[] optionStrings_4 = {MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.sendchatindex-(MainLogic.getInstance().uiEquipment.chatindex - 1)][2]};
                        String[] optionStrings_4 = {MainLogic.getInstance().uiEquipment.chatOtherplayerName};
//                        System.out.println("ccccccccccc  :::" + MainLogic.getInstance().uiEquipment.chatOtherplayerName);
                        choiceGroupPrivate = new ChoiceGroup("私聊对象", Choice.EXCLUSIVE, optionStrings_4, null);
                        this.append(choiceGroupPrivate);
                        //
                        BUTTON_CMD = new Command("好友列表", Command.ITEM, 2);
                        button = new StringItem(null, "好友列表", item.BUTTON);
                        button.setItemCommandListener(this);
                        button.setDefaultCommand(BUTTON_CMD);
                        this.append(button);
//                        this.cmdOkprivate = new Command("好友列表", Command.OK, 1);
//                        this.addCommand(cmdOkprivate);
//                        setCommandListener(this);
                        break;
                    case 4:
                        String[] optionStrings_7 = {"队伍"};
                        ChoiceGroup options_7 = new ChoiceGroup("频道", Choice.EXCLUSIVE, optionStrings_7, null);
                        this.append(options_7);
                        break;
                    case 5:
                        String[] optionStrings_5 = {"帮派"};
                        ChoiceGroup options_5 = new ChoiceGroup("频道", Choice.EXCLUSIVE, optionStrings_5, null);
                        this.append(options_5);
                        break;
                    case 6:
                        break;
                }
                break;
            case Constant.GAME_UI_CHAT_SECOND:
                this.cmdOk = new Command("发送", Command.OK, 1);
//                this.cmdOk1 = new Command("表情", Command.OK, 1);
//                this.cmdOk2 = new Command("物品", Command.OK, 1);
//                this.cmdOk3 = new Command("任务", Command.OK, 1);
                this.cmdOk4 = new Command("重复", Command.OK, 1);
                this.cmdCancel = new Command("返回", Command.CANCEL, 1);
                this.addCommand(cmdOk);
//                this.addCommand(cmdOk1);
//                this.addCommand(cmdOk2);
//                this.addCommand(cmdOk3);
                this.addCommand(cmdOk4);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                if (MainLogic.getInstance().uiEquipment.chatSecondSelect == 0) {
                    commonInput.setTextField("内容：(少于30字)", MainLogic.getInstance().uiEquipment.sStrArray[0], 30, TextField.ANY);
                    this.append(commonInput);
                    String[] optionStrings_3 = {"私聊"};
                    ChoiceGroup options_3 = new ChoiceGroup("频道", Choice.EXCLUSIVE, optionStrings_3, null);
                    this.append(options_3);
                    if (MainLogic.getInstance().uiEquipment.chatSelectindex == 0) {
                    }
                    switch (MainLogic.getInstance().uiEquipment.chatSelectindex) {
                        case 0://综合chatStrArray
                            MainLogic.getInstance().uiEquipment.chatOtherplayerName =
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1))][2];
                            MainLogic.getInstance().uiEquipment.chatOtherplayerId =
                                    Long.parseLong(MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1))][4]);
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            break;
                        case 1://世界
                            MainLogic.getInstance().uiEquipment.chatOtherplayerName =
                                    MainLogic.getInstance().uiEquipment.chatStrArray_world[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][2];
                            MainLogic.getInstance().uiEquipment.chatOtherplayerId =
                                    Long.parseLong(MainLogic.getInstance().uiEquipment.chatStrArray_world[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][4]);
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            break;
                        case 2://当前
                            MainLogic.getInstance().uiEquipment.chatOtherplayerName =
                                    MainLogic.getInstance().uiEquipment.chatStrArray_current[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][2];
                            MainLogic.getInstance().uiEquipment.chatOtherplayerId =
                                    Long.parseLong(MainLogic.getInstance().uiEquipment.chatStrArray_current[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][4]);
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            break;
                        case 3://私聊
                            MainLogic.getInstance().uiEquipment.chatOtherplayerName =
                                    MainLogic.getInstance().uiEquipment.chatStrArray_Private[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][2];
                            MainLogic.getInstance().uiEquipment.chatOtherplayerId =
                                    Long.parseLong(MainLogic.getInstance().uiEquipment.chatStrArray_Private[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][4]);
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            break;
                        case 4://队伍
                            MainLogic.getInstance().uiEquipment.chatOtherplayerName =
                                    MainLogic.getInstance().uiEquipment.chatStrArray_team[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][2];
                            MainLogic.getInstance().uiEquipment.chatOtherplayerId =
                                    Long.parseLong(MainLogic.getInstance().uiEquipment.chatStrArray_team[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][4]);
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            break;
                        case 5://帮派
                            MainLogic.getInstance().uiEquipment.chatOtherplayerName =
                                    MainLogic.getInstance().uiEquipment.chatStrArray_gang[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][2];
                            MainLogic.getInstance().uiEquipment.chatOtherplayerId =
                                    Long.parseLong(MainLogic.getInstance().uiEquipment.chatStrArray_gang[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][4]);
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            break;
                        case 6://系统
                            MainLogic.getInstance().uiEquipment.chatOtherplayerName =
                                    MainLogic.getInstance().uiEquipment.chatStrArray_system[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][2];
                            MainLogic.getInstance().uiEquipment.chatOtherplayerId =
                                    Long.parseLong(MainLogic.getInstance().uiEquipment.chatStrArray_system[MainLogic.getInstance().uiEquipment.sendchatindex - (MainLogic.getInstance().uiEquipment.chatindex - 1)][4]);
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            break;
                    }
                    Tools.printLog("vvvvvvvvvv  :::" + MainLogic.getInstance().uiEquipment.chatOtherplayerName);
                    String[] optionStrings_4 = {MainLogic.getInstance().uiEquipment.chatOtherplayerName};
                    ChoiceGroup options_4 = new ChoiceGroup("发往", Choice.EXCLUSIVE, optionStrings_4, null);
                    this.append(options_4);
                }
                if (MainLogic.getInstance().uiEquipment.chatSecondSelect == 2) {
                    commonInput.setTextField("内容：(少于30字)", MainLogic.getInstance().uiEquipment.sStrArray[0], 30, TextField.ANY);
                    this.append(commonInput);
                    String[] optionStrings_3 = {"世界", "区域"};
                    options_second = new ChoiceGroup("频道", Choice.EXCLUSIVE, optionStrings_3, null);
                    this.append(options_second);
                }
                break;
            case Constant.GAME_UI_SEND_EMAIL:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                switch (MainLogic.getInstance().uiEquipment.SendEmail_State) {
                    case 1:
                    case 2:
                    case 3:
//                          MainLogic.getInstance().uiEquipment.sendEmail_name = name;
//                                MainLogic.getInstance().uiEquipment.sendEmail_title = title;
//                                MainLogic.getInstance().uiEquipment.sendEmail_text = text;
                        if (Constant.CMD_MAIL_TYPE == 0) {
                            commonInput.setTextField("收件人姓名：(少于10字)", MainLogic.getInstance().uiEquipment.sendEmail_name, 20, TextField.ANY);
                        } else {
                            item = new StringItem("收件人姓名：", "GM");
                            this.append(item);
                        }

                        commonInput2.setTextField("标题：(少于8字)", MainLogic.getInstance().uiEquipment.sendEmail_title, 8, TextField.ANY);
                        commonInput3.setTextField("正文：(少于100字)", MainLogic.getInstance().uiEquipment.sendEmail_text, 100, TextField.ANY);
//                        commonInput.setTextField("收件人姓名：(少于10字)", MainLogic.getInstance().uiEquipment.sStrArray[0], 20, TextField.ANY);
                        if (Constant.CMD_MAIL_TYPE == 0) {
                            this.append(commonInput);
                        }
                        if (Constant.CMD_MAIL_TYPE == 0) {
                            BUTTON_CMD = new Command("好友列表", Command.ITEM, 2);
                            button = new StringItem(null, "好友列表", item.BUTTON);
                            button.setItemCommandListener(this);
                            button.setDefaultCommand(BUTTON_CMD);
                            this.append(button);
                        }
//                        commonInput2.setTextField("标题：(少于8字)", MainLogic.getInstance().uiEquipment.sStrArray[1], 8, TextField.ANY);
                        this.append(commonInput2);

//                        commonInput3.setTextField("正文：(少于100字)", MainLogic.getInstance().uiEquipment.sStrArray[2], 100, TextField.ANY);
                        this.append(commonInput3);
                        break;
                    case 4:
                        commonInput2.setTextField("金：", MainLogic.getInstance().uiEquipment.sStrArray_gold[0], 4, TextField.NUMERIC);
                        commonInput3.setTextField("银：", MainLogic.getInstance().uiEquipment.sStrArray_silver[0], 2, TextField.NUMERIC);
                        commonInput4.setTextField("铜：", MainLogic.getInstance().uiEquipment.sStrArray_copper[0], 2, TextField.NUMERIC);
                        item = new StringItem("现有龙币",
                                MainLogic.getInstance().uiEquipment.havemoney_gold + "金"
                                + MainLogic.getInstance().uiEquipment.havemoney_silver + "银"
                                + MainLogic.getInstance().uiEquipment.havemoney_copper + "铜");
                        this.append(commonInput2);
                        this.append(commonInput3);
                        this.append(commonInput4);
                        this.append(item);
                        break;
                }
                break;
            case Constant.GAME_UI_CREATE_TONG:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                if (GameBean.STR_CMD_TONG_NAME != null && GameBean.STR_CMD_TONG_NAME.length() > 0) {
                    commonInput.setTextField("请输入帮派的名称：", GameBean.STR_CMD_TONG_NAME, 6, TextField.ANY);
                } else {
                    commonInput.setTextField("请输入帮派的名称：", "", 6, TextField.ANY);
                }
                if (GameBean.STR_CMD_TONG_NO != null && GameBean.STR_CMD_TONG_NO.length() > 0) {
                    commonInput2.setTextField("请输入帮派的代号：", GameBean.STR_CMD_TONG_NO, 6, TextField.ANY);
                } else {
                    commonInput2.setTextField("请输入帮派的代号：", "", 6, TextField.ANY);
                }
                if (GameBean.STR_CMD_TONG_ADS != null && GameBean.STR_CMD_TONG_ADS.length() > 0) {
                    commonInput3.setTextField("请输入帮派的宣言：", GameBean.STR_CMD_TONG_ADS, 30, TextField.ANY);
                } else {
                    commonInput3.setTextField("请输入帮派的宣言：", "", 30, TextField.ANY);
                }
                this.append(commonInput);
                this.append(commonInput2);
                this.append(commonInput3);
                break;
            case Constant.GAME_UI_NPC_TALK:
                switch (byUiState) {
                    case 0:
                        commonInput.setTextField("请输入您获得的激活码:", "", 15, TextField.ANY);
                        this.cmdOk = new Command("确定", Command.OK, 0);
                        this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                        this.append(commonInput);
                        this.addCommand(cmdOk);
                        this.addCommand(cmdCancel);
                        setCommandListener(this);
                        break;
                    case 1:
                        this.cmdOk = new Command("确定", Command.OK, 0);
                        this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                        this.addCommand(cmdOk);
                        this.addCommand(cmdCancel);
                        setCommandListener(this);
                        if (GameBean.STR_CMD_TONG_ADS != null && GameBean.STR_CMD_TONG_ADS.length() > 0) {
                            commonInput.setTextField("请输入帮派的宣言：", GameBean.STR_CMD_TONG_ADS, 30, TextField.ANY);
                        } else {
                            commonInput.setTextField("请输入帮派的宣言：", "", 30, TextField.ANY);
                        }
                        this.append(commonInput);
                        break;
                }
                break;
            case Constant.GAME_UI_PACKAGE:
                //移动分解物品
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                commonInput.setTextField("请输入您要移动的物品数量：", String.valueOf(MainLogic.getInstance().uiPackage.shMoveNum), 5, TextField.NUMERIC);
                this.append(commonInput);
                break;
            case Constant.GAME_UI_FRIEND_LIST:
                switch (this.byUiState) {
                    case 1://添加好友
                        this.cmdOk = new Command("加为好友", Command.OK, 0);
                        commonInput.setTextField("请输入好友名称：", "", 15, TextField.ANY);
                        break;
                    case 2://添加黑名单
                        this.cmdOk = new Command("加入黑名单", Command.OK, 0);
                        commonInput.setTextField("请输入被填入黑名单人的名称：", "", 15, TextField.ANY);
                        break;
                    case 3://添加仇人
                        this.cmdOk = new Command("加为仇人", Command.OK, 0);
                        commonInput.setTextField("请输入仇人：", "", 15, TextField.ANY);
                        break;
                }
                this.append(commonInput);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                break;
            case Constant.GAME_UI_TRADE:
                int iGold = (int) (MainLogic.getInstance().uiInterFace.store.lMoney / 10000);
                int iSilver = (int) ((MainLogic.getInstance().uiInterFace.store.lMoney - iGold * 10000) / 100);
                int iCopper = (int) (MainLogic.getInstance().uiInterFace.store.lMoney - iGold * 10000 - iSilver * 100);
                commonInput2.setTextField("金：", String.valueOf(iGold), 4, TextField.NUMERIC);
                commonInput3.setTextField("银：", String.valueOf(iSilver), 2, TextField.NUMERIC);
                commonInput4.setTextField("铜：", String.valueOf(iCopper), 2, TextField.NUMERIC);
                item = new StringItem("您现在共有龙币：", Tools.moneyConvert(MainLogic.getInstance().uiInterFace.store.lPlayerMoney));
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.append(commonInput2);
                this.append(commonInput3);
                this.append(commonInput4);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                this.append(item);
                setCommandListener(this);
                break;
            case Constant.GAME_UI_PET_EQUIP:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("返回", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                commonInput.setTextField("宠物名称：", GameBean.STR_CMD_GOODS_NAME, 15, TextField.ANY);
                this.append(commonInput);
                setCommandListener(this);
                break;
            case Constant.GAME_UI_SET:
                switch (byUiState) {
                    case 1://密码修改
                        Rms.loadGame(Constant.RMS_LOGIN_USENAME_PASSWORD);
                        commonInput.setTextField("请输入帐号：", "", Constant.MAX_USER_NAME_LENGTH, TextField.ANY);
                        commonInput2.setTextField("请输入密码：", "", Constant.MAX_USER_PASSWORD_LENGTH, TextField.PASSWORD);
                        commonInput3.setTextField("请输入新密码：", "", Constant.MAX_USER_PASSWORD_LENGTH, TextField.PASSWORD);
                        cmdOk = new Command("确定", Command.OK, 0);
                        cmdCancel = new Command("返回", Command.CANCEL, 1);
                        choiceGroupOne = new ChoiceGroup("密码修改方式", Choice.EXCLUSIVE,
                                new String[]{"通过登陆密码修改登陆密码", "通过二级密码修改登陆密码", "通过二级密码修改二级密码"}, null);
                        append(commonInput);
                        append(choiceGroupOne);
                        append(commonInput2);
                        append(commonInput3);
                        addCommand(cmdOk);
                        addCommand(cmdCancel);
                        setCommandListener(this);
                        break;
                    case 2://联网设置
                        String[] choices = new String[]{"自动联网适配", "CMWAP", "CMNET", "联通接入", "互联网接入"};
                        choiceGroupOne = new ChoiceGroup("请选择联网方式", Choice.EXCLUSIVE, choices, null);
                        append(choiceGroupOne);
                        cmdOk = new Command("确定", Command.OK, 0);
                        cmdCancel = new Command("返回", Command.CANCEL, 1);
                        addCommand(cmdOk);
                        addCommand(cmdCancel);
                        setCommandListener(this);
                        break;
                }
                break;
            case Constant.GAME_UI_STORE_BUY:
            case Constant.GAME_UI_WAGE_STORE:
            case Constant.GAME_UI_INGOT_RECORD:
            case Constant.GAME_UI_INGOT_STORE:
                //购买的物品数量
                commonInput.setTextField("请输入您要购买的物品数量：", "", 3, TextField.NUMERIC);
                this.append(commonInput);
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                break;
            case Constant.GAME_UI_PLAYER_STALL:
                switch (this.byUiState) {
                    case 0:
                    case 1:
                        commonInput2.setTextField("金：", "", 4, TextField.NUMERIC);
                        commonInput3.setTextField("银：", "", 3, TextField.NUMERIC);
                        commonInput4.setTextField("铜：", "", 3, TextField.NUMERIC);
                        this.cmdOk = new Command("确定", Command.OK, 0);
                        this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                        this.append(commonInput2);
                        this.append(commonInput3);
                        this.append(commonInput4);
                        this.addCommand(cmdOk);
                        this.addCommand(cmdCancel);
                        setCommandListener(this);
                        break;
                    case 2:
                        commonInput.setTextField("购买数量：", "", 5, TextField.NUMERIC);
                        this.cmdOk = new Command("确定", Command.OK, 0);
                        this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                        this.append(commonInput);
                        this.addCommand(cmdOk);
                        this.addCommand(cmdCancel);
                        setCommandListener(this);
                        break;
                }
                break;
            case Constant.GAME_UI_HANGUP:
                commonInput.setTextField("幻蝶仙丹数量：", "", 5, TextField.NUMERIC);
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.append(commonInput);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                setCommandListener(this);
                break;
            case Constant.GAME_UI_CHARGE:
                this.cmdOk = new Command("确定", Command.OK, 0);
                this.cmdCancel = new Command("取消", Command.CANCEL, 1);
                this.addCommand(cmdOk);
                this.addCommand(cmdCancel);
                commonInput.setTextField("请输入充值卡号：", "", 25, TextField.ANY);
                commonInput2.setTextField("请输入充值卡密码：", "", 25, TextField.PASSWORD);
                this.append(commonInput);
                this.append(commonInput2);
                item = new StringItem(null, "您选择的是“" + MainLogic.getInstance().uiInterFace.gameSet.sArray[MainLogic.getInstance().uiInterFace.gameSet.bySelectIndex - 1] + "”");
                this.append(item);
                setCommandListener(this);
                break;
        }
        setFormButtons();
    }

    //监听事件
    public void commandAction(Command c, Displayable d) {
        switch (byGameState) {
            case Constant.GAME_UI_OPTION_LIST:
                if (c == cmdOk) {
                    String inputValue1 = commonInput.getString().trim();
                    String inputValue2 = commonInput2.getString().trim();
                    String inputValue3 = commonInput3.getString().trim();
                    String inputValue4 = commonInput4.getString().trim();
                    if (inputValue1.length() < Constant.MIN_USER_NAME_LENGTH || inputValue1.trim().length() > Constant.MAX_USER_NAME_LENGTH) {
                        alert = new Alert("提示", "用户名长度不正确(" + String.valueOf(Constant.MIN_USER_NAME_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_NAME_LENGTH) + "个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (!Tools.isNumOrletters(inputValue1)) {
                        alert = new Alert("提示", "用户名不支持中文，各种符号。", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue2.length() < Constant.MIN_USER_PASSWORD_LENGTH || inputValue2.length() > Constant.MAX_USER_PASSWORD_LENGTH) {
                        alert = new Alert("提示", "密码长度不正确(" + String.valueOf(Constant.MIN_USER_PASSWORD_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_PASSWORD_LENGTH) + "个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (!Tools.isNumOrletters(inputValue2)) {
                        alert = new Alert("提示", "密码不支持中文，各种符号。", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (!inputValue2.equals(inputValue3)) {
                        alert = new Alert("提示", "两次输入密码不一致！", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue4.length() < Constant.MIN_USER_PASSWORD_LENGTH || inputValue4.length() > Constant.MAX_USER_PASSWORD_LENGTH) {
                        alert = new Alert("提示", "二级密码长度不正确(" + String.valueOf(Constant.MIN_USER_PASSWORD_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_PASSWORD_LENGTH) + "个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (!Tools.isNumOrletters(inputValue4)) {
                        alert = new Alert("提示", "二级密码不支持中文，各种符号。", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        GameBean.STR_CMD_LOGIN_USENAME = inputValue1;
                        GameBean.STR_CMD_LOGIN_PASSWORD = inputValue2;
                        GameBean.STR_CMD_SUPER_PASSWORD = inputValue4;
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        MainGame.changeCanvas(MainGame.mainFrame);
                        LocalMsgManager.getInstance().httpConnect(Constant.MSG_LOCAL_HTTP_REGISTER);
                    }
                    inputValue1 = null;
                    inputValue2 = null;
                    alert = null;
                } else if (c == cmdCancel) {
                    MainGame.changeCanvas(MainGame.mainFrame);
                    //MainLogic.getInstance().inputInterFace = null;
                }
                break;
            case Constant.GAME_UI_LOGIN:
                if (c == cmdOk) {
                    String inputValue1 = commonInput.getString().trim();
                    String inputValue2 = commonInput2.getString().trim();
                    if (inputValue1.length() < Constant.MIN_USER_NAME_LENGTH || inputValue1.trim().length() > Constant.MAX_USER_NAME_LENGTH) {
                        alert = new Alert("提示", "用户名长度不正确(" + String.valueOf(Constant.MIN_USER_NAME_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_NAME_LENGTH) + "个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (!Tools.isNumOrletters(inputValue1)) {
                        alert = new Alert("提示", "用户名不支持中文，各种符号。", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue2.length() < Constant.MIN_USER_PASSWORD_LENGTH || inputValue2.length() > Constant.MAX_USER_PASSWORD_LENGTH) {
                        alert = new Alert("提示", "密码长度不正确(" + String.valueOf(Constant.MIN_USER_PASSWORD_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_PASSWORD_LENGTH) + "个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (!Tools.isNumOrletters(inputValue2)) {
                        alert = new Alert("提示", "密码不支持中文，各种符号。", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        MainLogic.getInstance().uiLogin.sArray[0] = inputValue1;
                        MainLogic.getInstance().uiLogin.sArray[1] = inputValue2;
                        MainLogic.getInstance().uiLogin.setGameUiState((byte) 1);
                        MainGame.changeCanvas(MainGame.mainFrame);
                    }
                    inputValue1 = null;
                    inputValue2 = null;
                    alert = null;
                } else if (c == cmdCancel) {
                    MainLogic.getInstance().uiLogin.setGameUiState((byte) 1);
                    MainGame.changeCanvas(MainGame.mainFrame);
                    //MainLogic.getInstance().inputInterFace = null;
                }
                break;
            case Constant.GAME_UI_CREATE_ROLE:
                if (c == cmdOk) {
                    if (this.byUiState == 4) {
                        String roleName = commonInput.getString().trim();
                        byte code = Tools.checkStringLegal(roleName, Constant.MIN_ROLE_NAME_LENGTH, Constant.MAX_ROLE_NAME_LENGTH);
                        if (code == 1) {
                            alert = new Alert("提示", "角色名称长度不正确(" + String.valueOf(Constant.MIN_ROLE_NAME_LENGTH) + "到" + String.valueOf(Constant.MAX_ROLE_NAME_LENGTH) + "个字符)!", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else if (code == 2) {
                            alert = new Alert("提示", "角色名称只能是中文数字和英文字母!", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else if (code == 0) {
                            MainLogic.getInstance().uiLogin.setGameUiState((byte) 1);
                            GameBean.STR_CMD_PLAYER_NICK = roleName.trim();
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                        }
                    }
                } else if (c == cmdCancel) {
                    MainLogic.getInstance().uiLogin.setGameUiState((byte) 1);
                    MainGame.changeCanvas(MainGame.mainFrame);
                    //MainLogic.getInstance().inputInterFace = null;
                }
                break;
            case Constant.GAME_UI_CHAT:
                if (c == cmdOk) {
                    String chatS = commonInput.getString();
                    if (chatS == null) {
                        alert = new Alert("提示", "发言不能为空", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (MainLogic.getInstance().uiEquipment.chatshoutType == 3
                            && MainLogic.getInstance().uiEquipment.chatOtherplayerName.equals("")) {
                        alert = new Alert("提示", "没有私聊对象，请在好友列表中选择私聊好友。", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        String newStr = chatS.trim();
                        if (newStr.indexOf("/%") != -1 && MainLogic.getInstance().uiEquipment.taskORitems_ID[1] != null) {
                            for (int i = 0; i < MainLogic.getInstance().uiEquipment.taskORitems_ID.length; i++) {
                                MainLogic.getInstance().uiEquipment.oldtaskORitems_ID[i] = MainLogic.getInstance().uiEquipment.taskORitems_ID[i];
                            }
                            MainLogic.getInstance().uiEquipment.taskORitems_ID[1] = MainLogic.getInstance().uiEquipment.taskORitems_ID[3]
                                    + MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                            newStr = newStr.substring(0, newStr.indexOf("/%") + 2)
                                    + MainLogic.getInstance().uiEquipment.taskORitems_ID[1]
                                    + newStr.substring(newStr.indexOf("/%") + 2, newStr.length());
                            MainLogic.getInstance().uiEquipment.taskORitems_items = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                        }
//                            MainLogic.getInstance().uiEquipment.oldword = newStr;
                        MainLogic.getInstance().uiEquipment.oldword = chatS.trim();
//                            Tools.printLog("newStr  :::" + newStr);
//                            Tools.printLog("newStr11  :::" + chatS.trim());
                        String[] chathead = {"[综]", "[世]", "[区]", "[队]", "[帮]", "[系]", "[私]"};
                        MainLogic.getInstance().uiEquipment.sStrArray[0] = chatS.trim();
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_SHOUT, Constant.SOCKET_MSG_TYPE_LOGIC);
//                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_ADD_CONTANT, Constant.SOCKET_MSG_TYPE_LOGIC);
//                            for (int a = 0; a < 5; a++) {
//                                MainLogic.getInstance().uiEquipment.sStrArray[0] = chatS.trim() + "" + a;
//                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_SHOUT, Constant.SOCKET_MSG_TYPE_LOGIC);
//                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_ADD_CONTANT, Constant.SOCKET_MSG_TYPE_LOGIC);
//                            }
                        byte shoutType = 2;
                        String otherplayer = "";
                        switch (MainLogic.getInstance().uiEquipment.chatshoutType) {
                            case 0://综合
                                shoutType = 2;
                                break;
                            case 1://世界
                                shoutType = 1;
                                break;
                            case 2://当前
                                shoutType = 2;
                                break;
                            case 3://私聊
                                shoutType = 6;
                                break;
                            case 4://队伍
                                shoutType = 3;
                                break;
                            case 5://帮派
                                shoutType = 4;
                                break;
                            case 6://系统
                                shoutType = 5;
                                break;
                        }
                        if (shoutType == 6) {
                            MainLogic.getInstance().uiEquipment.changeParagraph(chathead[shoutType]
                                    + MainLogic.getInstance().gamePlayer.sPlayerName
                                    + "对" + MainLogic.getInstance().uiEquipment.chatOtherplayerName + "：" + newStr,
                                    Constant.SCREEN_WIDTH - 10, 2);
                            //#if NOKIA_S60V5
                             MainLogic.getInstance().uiEquipment.changeNokiaParagraph(chathead[shoutType]
                                     + MainLogic.getInstance().gamePlayer.sPlayerName
                                     + "对" + MainLogic.getInstance().uiEquipment.chatOtherplayerName + "：" + newStr,
                                     MainLogic.getInstance().uiInterFace.UIchat_W, 2);
                            //#endif
                            otherplayer = MainLogic.getInstance().uiEquipment.chatOtherplayerName;
                            GameBean.BY_CMD_FRIEND_ID = MainLogic.getInstance().uiEquipment.chatOtherplayerId;
                            Tools.printLog("我跟对方私聊");
                            //MainLogic.getInstance().send(Constant.MSG_NET_CMD_ADD_CONTANT, Constant.SOCKET_MSG_TYPE_LOGIC);
//                            System.out.println(" 111 chatOtherplayerName " + MainLogic.getInstance().uiEquipment.chatOtherplayerName);
                            GameBean.BY_CMD_FRIEND_NAME = otherplayer;
                            GameBean.BY_CMD_FRIEND_TYPE = 4;
                            GameBean.BY_CMD_FRIEND_MODE = 2;
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_ADD_FRIEND, Constant.SOCKET_MSG_TYPE_LOGIC);
                        } else {
                            MainLogic.getInstance().uiEquipment.changeParagraph(chathead[shoutType]
                                    + MainLogic.getInstance().gamePlayer.sPlayerName
                                    + "：" + newStr,
                                    Constant.SCREEN_WIDTH - 10, 2);
                            //#if NOKIA_S60V5
                             MainLogic.getInstance().uiEquipment.changeNokiaParagraph(chathead[shoutType]
                                     + MainLogic.getInstance().gamePlayer.sPlayerName
                                     + "：" + newStr,
                                     MainLogic.getInstance().uiInterFace.UIchat_W, 2);
                            //#endif
                        }
//                        System.out.println("newStr 111   " + newStr);
//                        for (int k = 0; k < MainLogic.getInstance().uiEquipment.chatStrParagraph.length; k++) {
                        for (int k = MainLogic.getInstance().uiEquipment.chatStrParagraph.length - 1; k >= 0; k--) {
                            if (MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0] != null) {
                                if (MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0] != null) {
                                    String[][] newchat = new String[MainLogic.getInstance().uiEquipment.chatline_num][8];
                                    for (int j = 0; j < MainLogic.getInstance().uiEquipment.chatStrArray.length; j++) {
                                        newchat[j][0] = MainLogic.getInstance().uiEquipment.chatStrArray[j][0];
                                        newchat[j][1] = MainLogic.getInstance().uiEquipment.chatStrArray[j][1];
                                        newchat[j][2] = MainLogic.getInstance().uiEquipment.chatStrArray[j][2];
                                        newchat[j][3] = MainLogic.getInstance().uiEquipment.chatStrArray[j][3];
                                        newchat[j][4] = MainLogic.getInstance().uiEquipment.chatStrArray[j][4];
                                        newchat[j][5] = MainLogic.getInstance().uiEquipment.chatStrArray[j][5];
                                        newchat[j][6] = MainLogic.getInstance().uiEquipment.chatStrArray[j][6];
                                        newchat[j][7] = MainLogic.getInstance().uiEquipment.chatStrArray[j][7];
                                    }
                                    for (int a = 0; a < MainLogic.getInstance().uiEquipment.chatStrArray.length - 1; a++) {
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][0] = newchat[a + 1][0];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][1] = newchat[a + 1][1];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][2] = newchat[a + 1][2];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][3] = newchat[a + 1][3];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][4] = newchat[a + 1][4];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][5] = newchat[a + 1][5];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][6] = newchat[a + 1][6];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[a][7] = newchat[a + 1][7];
                                    }
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0] = ""
                                            + shoutType;
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][1] = MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0];
//                                Tools.printLog("cc   " + MainLogic.getInstance().uiEquipment.chatStrArray[7][1]);
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][2] = MainLogic.getInstance().gamePlayer.sPlayerName;
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][3] = otherplayer;
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][4] = "" + MainLogic.getInstance().gamePlayer.lPlayerID;
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][5] = MainLogic.getInstance().uiEquipment.taskORitems_ID[0];
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][6] = MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                    MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][7] = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                                    MainLogic.getInstance().uiEquipment.getshoutTypeChatStr(MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0],
                                            MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][1],
                                            MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][2],
                                            MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][3],
                                            MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][4],
                                            MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][5],
                                            MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][6],
                                            MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][7]);
                                } else {
                                    for (int i = 0; i < MainLogic.getInstance().uiEquipment.chatStrArray.length; i++) {
                                        if (MainLogic.getInstance().uiEquipment.chatStrArray[i][0] == null) {
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][0] = ""
                                                    + shoutType;
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][1] = MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0];
                                            Tools.printLog("aa   " + MainLogic.getInstance().uiEquipment.chatStrArray[i][1]);
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][2] = MainLogic.getInstance().gamePlayer.sPlayerName;
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][3] = otherplayer;
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][4] = "" + MainLogic.getInstance().gamePlayer.lPlayerID;
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][5] = MainLogic.getInstance().uiEquipment.taskORitems_ID[0];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][6] = MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[i][7] = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                                            MainLogic.getInstance().uiEquipment.getshoutTypeChatStr(MainLogic.getInstance().uiEquipment.chatStrArray[i][0],
                                                    MainLogic.getInstance().uiEquipment.chatStrArray[i][1], MainLogic.getInstance().uiEquipment.chatStrArray[i][2],
                                                    MainLogic.getInstance().uiEquipment.chatStrArray[i][3], MainLogic.getInstance().uiEquipment.chatStrArray[i][4],
                                                    MainLogic.getInstance().uiEquipment.chatStrArray[i][5], MainLogic.getInstance().uiEquipment.chatStrArray[i][6],
                                                    MainLogic.getInstance().uiEquipment.chatStrArray[i][7]);
                                            break;
                                        }
                                    }
                                }

                            }
                        }

                        if (shoutType == 5) {
                            MainLogic.getInstance().uiEquipment.getSysUIchat(shoutType,
                                    MainLogic.getInstance().uiEquipment.taskORitems_ID[1],
                                    MainLogic.getInstance().uiEquipment.taskORitems_ID[2]);
                        } else {
                            MainLogic.getInstance().uiEquipment.getUIchat(shoutType,
                                    MainLogic.getInstance().uiEquipment.taskORitems_ID[1],
                                    MainLogic.getInstance().uiEquipment.taskORitems_ID[2]);
                        }


                        switch (GameBean.BY_PRE_GAME_UI_STATE) {
                            case Constant.GAME_UI_CHAT:
                                MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, false);
                                MainGame.changeCanvas(MainGame.mainFrame);
                                //MainLogic.getInstance().inputInterFace = null;
                                break;
                            case Constant.GAME_UI_TONG_MEMBER_LIST:
                            case Constant.GAME_UI_FRIEND_LIST:
                            case Constant.GAME_UI_NEAR_PLAYER_LIST:
                            case Constant.GAME_UI_VIEW_OTHER_PLAYER:
                            case Constant.GAME_UI_ROAM:
                            case Constant.GAME_UI_TEAM_INFO:
                                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                                MainGame.changeCanvas(MainGame.mainFrame);
                                //MainLogic.getInstance().inputInterFace = null;
                                break;
                        }
                        GameBean.BY_PRE_GAME_UI_STATE = -1;
                    }
                } else if (c == BUTTON_CMD) {
//                    System.out.println("11111111111111111111111");
                } else if (c == cmdOk1) {//插入表情
                    MainLogic.getInstance().uiEquipment.smileindex = 0;
                    inputInterSmile = MainLogic.getInstance().inputInterFace;
                    MainLogic.getInstance().pushState(Constant.GAME_UI_SMILE, false);
                    MainGame.changeCanvas(MainGame.mainFrame);
                } else if (c == cmdOk2) {//插入物品
                    if (MainLogic.getInstance().uiEquipment.taskORitems_ID[0] != null) {
                        alert = new Alert("提示", "只能插入一个任务或者物品", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        inputInterItems = MainLogic.getInstance().inputInterFace;
                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                        MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                        MainGame.changeCanvas(MainGame.mainFrame);
                    }
                } else if (c == cmdOk3) {//插入任务
                    if (MainLogic.getInstance().uiEquipment.taskORitems_ID[0] != null) {
                        alert = new Alert("提示", "只能插入一个任务或者物品", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        inputInterTask = MainLogic.getInstance().inputInterFace;
                        MainLogic.getInstance().uiInterFace.npcTalk.openTaskList();
                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                        MainGame.changeCanvas(MainGame.mainFrame);
                    }
                } else if (c == cmdOk4) {
                    MainLogic.getInstance().uiEquipment.sStrArray[0] = MainLogic.getInstance().uiEquipment.oldword;
                    MainLogic.getInstance().uiEquipment.taskORitems_new = MainLogic.getInstance().uiEquipment.oldtaskORitems_new;
                    MainLogic.getInstance().inputInterFace.commonInput.setString(MainLogic.getInstance().uiEquipment.sStrArray[0]);
                    for (int i = 0; i < MainLogic.getInstance().uiEquipment.taskORitems_ID.length; i++) {
                        MainLogic.getInstance().uiEquipment.taskORitems_ID[i] = MainLogic.getInstance().uiEquipment.oldtaskORitems_ID[i];
                    }
                    MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                } //                else if (c == cmdOkprivate) {//好友列表
                //                    System.out.println("333333333333333333333333333333");
                //                    GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                //                    MainLogic.getInstance().pushState(Constant.GAME_UI_FRIEND_LIST, false);
                //                    MainGame.changeCanvas(MainGame.mainFrame);
                //                }
                else if (c == cmdCancel) {
                    switch (GameBean.BY_PRE_GAME_UI_STATE) {
                        case Constant.GAME_UI_CHAT:
                            MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, false);
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                            break;
                        case Constant.GAME_UI_ROAM:
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                            break;
                        case Constant.GAME_UI_TEAM_INFO:
                            MainLogic.getInstance().pushState(Constant.GAME_UI_TEAM_INFO, false);
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                            break;
                        case Constant.GAME_UI_FRIEND_LIST:
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_FRIEND_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
                            GameBean.b_WAIT_NET_MSG_BACK = true;
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                            break;
                        case Constant.GAME_UI_NEAR_PLAYER_LIST:
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_NEAR_PLAYERS, Constant.SOCKET_MSG_TYPE_LOGIC);
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                            break;
                        case Constant.GAME_UI_TONG_MEMBER_LIST:
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, false);
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_TONG_MEMBER_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                            break;
                        case Constant.GAME_UI_VIEW_OTHER_PLAYER:
                            MainLogic.getInstance().pushState(Constant.GAME_UI_VIEW_OTHER_PLAYER, true);
                            MainLogic.getInstance().uiInterFace.setLockSelect(2);
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                            break;
                    }
                    GameBean.BY_PRE_GAME_UI_STATE = -1;
                }
                break;
            case Constant.GAME_UI_CHAT_SECOND:
                if (c == cmdOk) {
                    if (MainLogic.getInstance().uiEquipment.chatSecondSelect == 0) {
                        String chatS = commonInput.getString();
                        if (chatS == null) {
                            alert = new Alert("提示", "发言不能为空", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else {
                            String newStr = chatS.trim();
                            if (newStr.indexOf("/%") != -1 && MainLogic.getInstance().uiEquipment.taskORitems_ID[1] != null) {
                                for (int i = 0; i < MainLogic.getInstance().uiEquipment.taskORitems_ID.length; i++) {
                                    MainLogic.getInstance().uiEquipment.oldtaskORitems_ID[i] = MainLogic.getInstance().uiEquipment.taskORitems_ID[i];
                                }
                                MainLogic.getInstance().uiEquipment.taskORitems_ID[1] = MainLogic.getInstance().uiEquipment.taskORitems_ID[3]
                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                newStr = newStr.substring(0, newStr.indexOf("/%") + 2)
                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[1]
                                        + newStr.substring(newStr.indexOf("/%") + 2, newStr.length());
                                MainLogic.getInstance().uiEquipment.taskORitems_items = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                            }
                            MainLogic.getInstance().uiEquipment.oldword = chatS.trim();
                            String[] chathead = {"[综]", "[世]", "[区]", "[队]", "[帮]", "[系]", "[私]"};
                            MainLogic.getInstance().uiEquipment.sStrArray[0] = chatS.trim();
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_SHOUT, Constant.SOCKET_MSG_TYPE_LOGIC);
                            byte shoutType = 6;
                            String otherplayer = "";
                            otherplayer = MainLogic.getInstance().uiEquipment.chatOtherplayerName;
                            MainLogic.getInstance().uiEquipment.changeParagraph(chathead[6]
                                    + MainLogic.getInstance().gamePlayer.sPlayerName
                                    + "对" + otherplayer + "：" + newStr,
                                    Constant.SCREEN_WIDTH - 10, 2);
                            //#if NOKIA_S60V5
                             MainLogic.getInstance().uiEquipment.changeNokiaParagraph(chathead[6]
                                     + MainLogic.getInstance().gamePlayer.sPlayerName
                                     + "对" + otherplayer + "：" + newStr,
                                     MainLogic.getInstance().uiInterFace.UIchat_W, 2);
                            //#endif
//                            System.out.println(" 222 chatOtherplayerName " + otherplayer);
//                            for (int k = 0; k < MainLogic.getInstance().uiEquipment.chatStrParagraph.length; k++) {
                            for (int k = MainLogic.getInstance().uiEquipment.chatStrParagraph.length - 1; k >= 0; k--) {
                                if (MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0] != null) {
                                    if (MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0] != null) {
                                        String[][] newchat = new String[MainLogic.getInstance().uiEquipment.chatline_num][8];
                                        for (int j = 0; j < MainLogic.getInstance().uiEquipment.chatStrArray.length; j++) {
                                            newchat[j][0] = MainLogic.getInstance().uiEquipment.chatStrArray[j][0];
                                            newchat[j][1] = MainLogic.getInstance().uiEquipment.chatStrArray[j][1];
                                            newchat[j][2] = MainLogic.getInstance().uiEquipment.chatStrArray[j][2];
                                            newchat[j][3] = MainLogic.getInstance().uiEquipment.chatStrArray[j][3];
                                            newchat[j][4] = MainLogic.getInstance().uiEquipment.chatStrArray[j][4];
                                            newchat[j][5] = MainLogic.getInstance().uiEquipment.chatStrArray[j][5];
                                            newchat[j][6] = MainLogic.getInstance().uiEquipment.chatStrArray[j][6];
                                            newchat[j][7] = MainLogic.getInstance().uiEquipment.chatStrArray[j][7];
                                        }
                                        for (int a = 0; a < MainLogic.getInstance().uiEquipment.chatStrArray.length - 1; a++) {
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][0] = newchat[a + 1][0];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][1] = newchat[a + 1][1];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][2] = newchat[a + 1][2];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][3] = newchat[a + 1][3];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][4] = newchat[a + 1][4];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][5] = newchat[a + 1][5];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][6] = newchat[a + 1][6];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][7] = newchat[a + 1][7];
                                        }
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0] = ""
                                                + shoutType;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][1] = MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0];
//                                Tools.printLog("cc   " + MainLogic.getInstance().uiEquipment.chatStrArray[7][1]);
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][2] = MainLogic.getInstance().gamePlayer.sPlayerName;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][3] = otherplayer;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][4] = "" + MainLogic.getInstance().gamePlayer.lPlayerID;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][5] = MainLogic.getInstance().uiEquipment.taskORitems_ID[0];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][6] = MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][7] = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                                        MainLogic.getInstance().uiEquipment.getshoutTypeChatStr(MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][1],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][2],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][3],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][4],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][5],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][6],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][7]);
                                    } else {
                                        for (int i = 0; i < MainLogic.getInstance().uiEquipment.chatStrArray.length; i++) {
                                            if (MainLogic.getInstance().uiEquipment.chatStrArray[i][0] == null) {
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][0] = ""
                                                        + shoutType;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][1] = MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0];
//                                        Tools.printLog("aa   " + MainLogic.getInstance().uiEquipment.chatStrArray[i][1]);
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][2] = MainLogic.getInstance().gamePlayer.sPlayerName;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][3] = otherplayer;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][4] = "" + MainLogic.getInstance().gamePlayer.lPlayerID;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][5] = MainLogic.getInstance().uiEquipment.taskORitems_ID[0];
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][6] = MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][7] = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                                                MainLogic.getInstance().uiEquipment.getshoutTypeChatStr(MainLogic.getInstance().uiEquipment.chatStrArray[i][0],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][1], MainLogic.getInstance().uiEquipment.chatStrArray[i][2],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][3], MainLogic.getInstance().uiEquipment.chatStrArray[i][4],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][5], MainLogic.getInstance().uiEquipment.chatStrArray[i][6],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][7]);
                                                break;
                                            }
                                        }
                                    }

                                }
                            }
                            if (shoutType == 5) {
                                MainLogic.getInstance().uiEquipment.getSysUIchat(shoutType,
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[1],
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[2]);
                            } else {
                                MainLogic.getInstance().uiEquipment.getUIchat(shoutType,
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[1],
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[2]);
                            }
                            MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, false);
                            MainGame.changeCanvas(MainGame.mainFrame);
//                            //MainLogic.getInstance().inputInterFace = null;
                            GameBean.BY_PRE_GAME_UI_STATE = -1;
                        }
                    }
                    if (MainLogic.getInstance().uiEquipment.chatSecondSelect == 2) {
                        String chatS = commonInput.getString();
                        if (chatS == null) {
                            alert = new Alert("提示", "发言不能为空", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else {
                            if (options_second.getSelectedIndex() == 0) {
                                MainLogic.getInstance().uiEquipment.chatshoutType = 1;
                            }
                            if (options_second.getSelectedIndex() == 1) {
                                MainLogic.getInstance().uiEquipment.chatshoutType = 2;
                            }
                            String newStr = chatS.trim();
                            if (newStr.indexOf("/%") != -1 && MainLogic.getInstance().uiEquipment.taskORitems_ID[1] != null) {
                                for (int i = 0; i < MainLogic.getInstance().uiEquipment.taskORitems_ID.length; i++) {
                                    MainLogic.getInstance().uiEquipment.oldtaskORitems_ID[i] = MainLogic.getInstance().uiEquipment.taskORitems_ID[i];
                                }
                                MainLogic.getInstance().uiEquipment.taskORitems_ID[1] = MainLogic.getInstance().uiEquipment.taskORitems_ID[3]
                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                newStr = newStr.substring(0, newStr.indexOf("/%") + 2)
                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[1]
                                        + newStr.substring(newStr.indexOf("/%") + 2, newStr.length());
                                MainLogic.getInstance().uiEquipment.taskORitems_items = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                            }
                            MainLogic.getInstance().uiEquipment.oldword = chatS.trim();
                            String[] chathead = {"[综]", "[世]", "[区]", "[队]", "[帮]", "[系]", "[私]"};
                            MainLogic.getInstance().uiEquipment.sStrArray[0] = chatS.trim();
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_SHOUT, Constant.SOCKET_MSG_TYPE_LOGIC);
                            byte shoutType = 2;
                            String otherplayer = "";
                            switch (MainLogic.getInstance().uiEquipment.chatshoutType) {
                                case 0://综合
                                    shoutType = 2;
                                    break;
                                case 1://世界
                                    shoutType = 1;
                                    break;
                                case 2://当前
                                    shoutType = 2;
                                    break;
                                case 3://私聊
                                    shoutType = 6;
                                    break;
                                case 4://队伍
                                    shoutType = 3;
                                    break;
                                case 5://帮派
                                    shoutType = 4;
                                    break;
                                case 6://系统
                                    shoutType = 5;
                                    break;
                            }
                            if (shoutType == 6) {
                                otherplayer = MainLogic.getInstance().uiEquipment.chatOtherplayerName;
                                MainLogic.getInstance().uiEquipment.changeParagraph(chathead[shoutType]
                                        + MainLogic.getInstance().gamePlayer.sPlayerName
                                        + "对" + otherplayer + "：" + newStr,
                                        Constant.SCREEN_WIDTH - 10, 2);
                                //#if NOKIA_S60V5
                                 MainLogic.getInstance().uiEquipment.changeNokiaParagraph(chathead[shoutType]
                                         + MainLogic.getInstance().gamePlayer.sPlayerName
                                         + "对" + otherplayer + "：" + newStr,
                                         MainLogic.getInstance().uiInterFace.UIchat_W, 2);
                                //#endif
//                                System.out.println(" 333 chatOtherplayerName " +otherplayer);
                            } else {
                                MainLogic.getInstance().uiEquipment.changeParagraph(chathead[shoutType]
                                        + MainLogic.getInstance().gamePlayer.sPlayerName
                                        + "：" + newStr,
                                        Constant.SCREEN_WIDTH - 10, 2);
                                //#if NOKIA_S60V5
                                 MainLogic.getInstance().uiEquipment.changeNokiaParagraph(chathead[shoutType]
                                         + MainLogic.getInstance().gamePlayer.sPlayerName
                                         + "：" + newStr,
                                         MainLogic.getInstance().uiInterFace.UIchat_W, 2);
                                //#endif
                            }

//                            for (int k = 0; k < MainLogic.getInstance().uiEquipment.chatStrParagraph.length; k++) {
                            for (int k = MainLogic.getInstance().uiEquipment.chatStrParagraph.length - 1; k >= 0; k--) {
                                if (MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0] != null) {
                                    if (MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0] != null) {
                                        String[][] newchat = new String[MainLogic.getInstance().uiEquipment.chatline_num][8];
                                        for (int j = 0; j < MainLogic.getInstance().uiEquipment.chatStrArray.length; j++) {
                                            newchat[j][0] = MainLogic.getInstance().uiEquipment.chatStrArray[j][0];
                                            newchat[j][1] = MainLogic.getInstance().uiEquipment.chatStrArray[j][1];
                                            newchat[j][2] = MainLogic.getInstance().uiEquipment.chatStrArray[j][2];
                                            newchat[j][3] = MainLogic.getInstance().uiEquipment.chatStrArray[j][3];
                                            newchat[j][4] = MainLogic.getInstance().uiEquipment.chatStrArray[j][4];
                                            newchat[j][5] = MainLogic.getInstance().uiEquipment.chatStrArray[j][5];
                                            newchat[j][6] = MainLogic.getInstance().uiEquipment.chatStrArray[j][6];
                                            newchat[j][7] = MainLogic.getInstance().uiEquipment.chatStrArray[j][7];
                                        }
                                        for (int a = 0; a < MainLogic.getInstance().uiEquipment.chatStrArray.length - 1; a++) {
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][0] = newchat[a + 1][0];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][1] = newchat[a + 1][1];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][2] = newchat[a + 1][2];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][3] = newchat[a + 1][3];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][4] = newchat[a + 1][4];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][5] = newchat[a + 1][5];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][6] = newchat[a + 1][6];
                                            MainLogic.getInstance().uiEquipment.chatStrArray[a][7] = newchat[a + 1][7];
                                        }
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0] = ""
                                                + shoutType;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][1] = MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0];
//                                Tools.printLog("cc   " + MainLogic.getInstance().uiEquipment.chatStrArray[7][1]);
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][2] = MainLogic.getInstance().gamePlayer.sPlayerName;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][3] = otherplayer;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][4] = "" + MainLogic.getInstance().gamePlayer.lPlayerID;
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][5] = MainLogic.getInstance().uiEquipment.taskORitems_ID[0];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][6] = MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                        MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][7] = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                                        MainLogic.getInstance().uiEquipment.getshoutTypeChatStr(MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][0],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][1],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][2],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][3],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][4],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][5],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][6],
                                                MainLogic.getInstance().uiEquipment.chatStrArray[MainLogic.getInstance().uiEquipment.chatStrArray.length - 1][7]);
                                    } else {
                                        for (int i = 0; i < MainLogic.getInstance().uiEquipment.chatStrArray.length; i++) {
                                            if (MainLogic.getInstance().uiEquipment.chatStrArray[i][0] == null) {
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][0] = ""
                                                        + shoutType;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][1] = MainLogic.getInstance().uiEquipment.chatStrParagraph[k][0];
//                                        Tools.printLog("aa   " + MainLogic.getInstance().uiEquipment.chatStrArray[i][1]);
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][2] = MainLogic.getInstance().gamePlayer.sPlayerName;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][3] = otherplayer;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][4] = "" + MainLogic.getInstance().gamePlayer.lPlayerID;
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][5] = MainLogic.getInstance().uiEquipment.taskORitems_ID[0];
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][6] = MainLogic.getInstance().uiEquipment.taskORitems_ID[1];
                                                MainLogic.getInstance().uiEquipment.chatStrArray[i][7] = MainLogic.getInstance().uiEquipment.taskORitems_ID[2];
                                                MainLogic.getInstance().uiEquipment.getshoutTypeChatStr(MainLogic.getInstance().uiEquipment.chatStrArray[i][0],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][1], MainLogic.getInstance().uiEquipment.chatStrArray[i][2],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][3], MainLogic.getInstance().uiEquipment.chatStrArray[i][4],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][5], MainLogic.getInstance().uiEquipment.chatStrArray[i][6],
                                                        MainLogic.getInstance().uiEquipment.chatStrArray[i][7]);
                                                break;
                                            }
                                        }
                                    }

                                }
                            }
                            if (shoutType == 5) {
                                MainLogic.getInstance().uiEquipment.getSysUIchat(shoutType,
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[1],
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[2]);
                            } else {
                                MainLogic.getInstance().uiEquipment.getUIchat(shoutType,
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[1],
                                        MainLogic.getInstance().uiEquipment.taskORitems_ID[2]);
                            }
                            MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, false);
                            MainGame.changeCanvas(MainGame.mainFrame);
//                            //MainLogic.getInstance().inputInterFace = null;
                            GameBean.BY_PRE_GAME_UI_STATE = -1;
                        }
                    }
                } else if (c == cmdOk1) {//插入表情
                    MainLogic.getInstance().uiEquipment.smileindex = 0;
                    inputInterSmile = MainLogic.getInstance().inputInterFace;
                    MainLogic.getInstance().pushState(Constant.GAME_UI_SMILE, false);
                    MainGame.changeCanvas(MainGame.mainFrame);
                } else if (c == cmdOk2) {//插入物品
                    inputInterItems = MainLogic.getInstance().inputInterFace;
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_BAG, Constant.SOCKET_MSG_TYPE_LOGIC);
                    GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT_SECOND;
                    MainGame.changeCanvas(MainGame.mainFrame);
                } else if (c == cmdOk3) {//插入任务
                    if (MainLogic.getInstance().uiEquipment.taskORitems_ID[0] != null) {
                        alert = new Alert("提示", "只能插入一个任务或者物品", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        inputInterTask = MainLogic.getInstance().inputInterFace;
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_QUEST_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
//                        GameBean.b_INSERT_STATE = true;
                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT_SECOND;
                        MainGame.changeCanvas(MainGame.mainFrame);
                    }
                } else if (c == cmdOk4) {
                    MainLogic.getInstance().uiEquipment.sStrArray[0] = MainLogic.getInstance().uiEquipment.oldword;
                    MainLogic.getInstance().uiEquipment.taskORitems_new = MainLogic.getInstance().uiEquipment.oldtaskORitems_new;
                    MainLogic.getInstance().inputInterFace.commonInput.setString(MainLogic.getInstance().uiEquipment.sStrArray[0]);
                    for (int i = 0; i < MainLogic.getInstance().uiEquipment.taskORitems_ID.length; i++) {
                        MainLogic.getInstance().uiEquipment.taskORitems_ID[i] = MainLogic.getInstance().uiEquipment.oldtaskORitems_ID[i];
                    }
                    MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                } else if (c == cmdCancel) {
                    MainGame.changeCanvas(MainGame.mainFrame);
                    //MainLogic.getInstance().inputInterFace = null;
                    GameBean.BY_PRE_GAME_UI_STATE = -1;
                }
                break;
            case Constant.GAME_UI_SEND_EMAIL:
                switch (MainLogic.getInstance().uiEquipment.SendEmail_State) {
                    case 1:
                    case 2:
                    case 3:
                        if (c == this.cmdOk) {
                            String name;
                            if (Constant.CMD_MAIL_TYPE == 0) {
                                name = commonInput.getString();
                            } else {
                                name = "GM";
                            }
                            String title = commonInput2.getString();
                            String text = commonInput3.getString();

                            if (name == null || name.equals("")) {
                                alert = new Alert("提示", "收件人姓名不能为空", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else if (text == null || text.equals("")) {
                                alert = new Alert("提示", "邮件正文不能为空", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                MainLogic.getInstance().uiEquipment.sendEmail_name = name;
                                MainLogic.getInstance().uiEquipment.sendEmail_title = title;
                                MainLogic.getInstance().uiEquipment.sendEmail_text = text;
                                int start_X = 10;
                                int start_Y = 21;
                                int wordSpacing_H = 2;
                                int rect_h = Constant.SCREEN_HEIGHT - (start_Y + wordSpacing_H * 5 + Constant.FONT_SMALL.getHeight() * 4)
                                        - (25 + Constant.FONT_SMALL.getHeight() + 10) - 30;
                                MainLogic.getInstance().uiEquipment.sendEmailTextHeight = Tools.getParagraphHeight(MainLogic.getInstance().uiEquipment.sendEmail_text,
                                        Constant.SCREEN_WIDTH - 14, Constant.FONT_SMALL.getHeight());
                                MainLogic.getInstance().uiEquipment.getParagraphPage(MainLogic.getInstance().uiEquipment.sendEmail_text,
                                        Constant.SCREEN_WIDTH - 14,
                                        Constant.FONT_SMALL.getHeight(),
                                        rect_h);
                                if (Constant.CMD_MAIL_TYPE == 0) {
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_MAIL_CHECKUSER, Constant.SOCKET_MSG_TYPE_LOGIC);
                                }
                                MainLogic.getInstance().pushState(Constant.GAME_UI_SEND_EMAIL, false);
                                MainGame.changeCanvas(MainGame.mainFrame);
                            }
                        } else if (c == this.cmdCancel) {
                            MainLogic.getInstance().pushState(Constant.GAME_UI_SEND_EMAIL, false);
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                        }
                        break;
//                    case 2:
//                        if (c == this.cmdOk) {
//                            String title = commonInput.getString();
//                            MainLogic.getInstance().uiEquipment.sendEmail_title = title;
//                            MainGame.changeCanvas(MainGame.mainFrame);
//                        } else if (c == this.cmdCancel) {
//                            MainGame.changeCanvas(MainGame.mainFrame);
//                            //MainLogic.getInstance().inputInterFace = null;
//                        }
//                        break;
//                    case 3:
//                        if (c == this.cmdOk) {
//                            String text = commonInput.getString();
//                            if (text == null) {
//                                alert = new Alert("提示", "邮件正文不能为空", null, AlertType.INFO);
//                                MainGame.changeCanvas(alert);
//                            } else {
//                                MainLogic.getInstance().uiEquipment.sendEmail_text = text;
//                                int start_X = 10;
//                                int start_Y = 21;
//                                int wordSpacing_H = 2;
//                                int rect_h = Constant.SCREEN_HEIGHT - (start_Y + wordSpacing_H * 5 + Constant.FONT_SMALL.getHeight() * 4)
//                                        - (25 + Constant.FONT_SMALL.getHeight() * 3 + 10) - (30 - Constant.FONT_SMALL.getHeight());
//                                MainLogic.getInstance().uiEquipment.sendEmailTextHeight = Tools.getParagraphHeight(MainLogic.getInstance().uiEquipment.sendEmail_text,
//                                        Constant.SCREEN_WIDTH - 14, Constant.FONT_SMALL.getHeight());
//                                MainLogic.getInstance().uiEquipment.getParagraphPage(MainLogic.getInstance().uiEquipment.sendEmail_text,
//                                        Constant.SCREEN_WIDTH - 14,
//                                        Constant.FONT_SMALL.getHeight(),
//                                        rect_h);
//                                MainGame.changeCanvas(MainGame.mainFrame);
//                            }
//                        } else if (c == this.cmdCancel) {
//                            MainGame.changeCanvas(MainGame.mainFrame);
//                            //MainLogic.getInstance().inputInterFace = null;
//                        }
//                        break;
                    case 4:
                        if (c == this.cmdOk) {
                            String gold = commonInput2.getString();
                            if (gold == null
                                    || gold.equals("")) {
                                gold = "" + 0;
                            }
                            String silver = commonInput3.getString();
                            if (silver == null
                                    || silver.equals("")) {
                                silver = "" + 0;
                            }
                            String copper = commonInput4.getString();
                            if (copper == null
                                    || copper.equals("")) {
                                copper = "" + 0;
                            }
                            if (!Tools.isNumeric(gold)
                                    || !Tools.isNumeric(silver)
                                    || !Tools.isNumeric(copper)) {
                                alert = new Alert("提示", "输入金钱不合法", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                Tools.printLog("Integer.parseInt(gold)  ::  " + Long.parseLong(gold));
                                Tools.printLog("Integer.parseInt(silver)  ::  " + Long.parseLong(silver));
                                Tools.printLog("Integer.parseInt(copper)  ::  " + Long.parseLong(copper));
                                long getmoney = Long.parseLong(gold) * 10000 + Long.parseLong(silver) * 100 + Long.parseLong(copper);
                                long havemoney = MainLogic.getInstance().uiEquipment.havemoney_gold * 10000
                                        + MainLogic.getInstance().uiEquipment.havemoney_silver * 100
                                        + MainLogic.getInstance().uiEquipment.havemoney_copper;
                                Tools.printLog("getmoney  :: " + getmoney);
                                Tools.printLog("havemoney  :: " + havemoney);
                                if (getmoney > havemoney) {
                                    alert = new Alert("提示", "您的钱不够", null, AlertType.INFO);
                                    MainGame.changeCanvas(alert);
                                } else {
                                    MainLogic.getInstance().uiEquipment.money_gold = Long.parseLong(gold);
                                    MainLogic.getInstance().uiEquipment.money_silver = Long.parseLong(silver);
                                    MainLogic.getInstance().uiEquipment.money_copper = Long.parseLong(copper);
                                    MainGame.changeCanvas(MainGame.mainFrame);
                                }
                            }
                        } else if (c == this.cmdCancel) {
                            MainGame.changeCanvas(MainGame.mainFrame);
                            //MainLogic.getInstance().inputInterFace = null;
                        }
                        break;
                }
                break;
            case Constant.GAME_UI_CREATE_TONG:
                String inputValue1 = commonInput.getString().trim();
                String inputValue2 = commonInput2.getString().trim();
                String inputValue3 = commonInput3.getString().trim();
                if (c == this.cmdOk) {
                    if (inputValue1.length() < 3 || inputValue1.length() > 6) {
                        alert = new Alert("提示", "帮派名称的长度(3到6个字符)不正确", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue2.length() != 1) {
                        alert = new Alert("提示", "帮派代号的长度(1个字符)不正确", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue1.equals("")) {
                        alert = new Alert("提示", "请先输入帮派名称", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue1.indexOf(inputValue2) == -1) {
                        alert = new Alert("提示", "帮派代号必须是帮派名称中的一个字符", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue3.length() < 3 || inputValue3.length() > 50) {
                        alert = new Alert("提示", "帮派宣言的长度(3到30个字符)不正确", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        GameBean.STR_CMD_TONG_NAME = inputValue1;
                        GameBean.STR_CMD_TONG_NO = inputValue2;
                        GameBean.STR_CMD_TONG_ADS = inputValue3;
                        MainLogic.getInstance().uiInterFace.tong.byTongUiState = 0;
                        MainGame.changeCanvas(MainGame.mainFrame);
                        inputValue1 = null;
                        inputValue2 = null;
                        inputValue3 = null;
                    }
                } else if (c == this.cmdCancel) {
                    GameBean.STR_CMD_TONG_NAME = inputValue1;
                    GameBean.STR_CMD_TONG_NO = inputValue2;
                    GameBean.STR_CMD_TONG_ADS = inputValue3;
                    MainLogic.getInstance().uiInterFace.tong.byTongUiState = 0;
                    MainGame.changeCanvas(MainGame.mainFrame);
                    inputValue1 = null;
                    inputValue2 = null;
                    inputValue3 = null;
                }
                break;
            case Constant.GAME_UI_NPC_TALK:
                switch (byUiState) {
                    case 0:
                        if (c == cmdOk) {
                            GameBean.STR_CMD_CDKEY = commonInput.getString().trim();
                            if (Tools.checkStringLegal(GameBean.STR_CMD_CDKEY, 4, 20) == 0) {
                                MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                                MainGame.changeCanvas(MainGame.mainFrame);
                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_ACTIVATION, Constant.SOCKET_MSG_TYPE_LOGIC);
                                GameBean.STR_CMD_CDKEY = null;
                            } else {
                                alert = new Alert("提示", "您输入的激活码格式不正确!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            }
                        } else if (c == cmdCancel) {
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                            MainGame.changeCanvas(MainGame.mainFrame);
                        }
                        break;
                    case 1:
                        if (c == this.cmdOk) {
                            String inputValue = commonInput.getString().trim();
                            if (inputValue.length() < 3 || inputValue.length() > 50) {
                                alert = new Alert("提示", "帮派宣言的长度(3到30个字符)不正确", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                GameBean.STR_CMD_TONG_ADS = inputValue;
                                inputValue = null;
                                MainLogic.getInstance().send(Constant.MSG_NET_TONG_CHANGE_DESCRIPT, Constant.SOCKET_MSG_TYPE_LOGIC);
                                MainGame.changeCanvas(MainGame.mainFrame);
                            }
                        } else if (c == this.cmdCancel) {
                            GameBean.STR_CMD_TONG_ADS = commonInput.getString().trim();
                            MainGame.changeCanvas(MainGame.mainFrame);
                        }
                        break;
                }
                break;
            case Constant.GAME_UI_PACKAGE:
                if (c == this.cmdOk) {
                    if (Tools.isNumeric(commonInput.getString().trim())) {
                        int inputValue = Integer.parseInt(commonInput.getString().trim());
                        short max = MainLogic.uiPackage.getCurrentPackage().getGoodsStackNum(MainLogic.uiPackage.shPos);
                        if (inputValue <= 0 || inputValue > max) {
                            alert = new Alert("提示", "您输入的要移动的道具数量不正确(1到" + max + ")", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else {
                            MainLogic.uiPackage.shMoveNum = (short) inputValue;
                            MainGame.changeCanvas(MainGame.mainFrame);
                        }
                    } else {
                        alert = new Alert("提示", "您输入的不是数字!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    }
                } else if (c == this.cmdCancel) {
                    MainLogic.uiPackage.shMoveNum = 0;
                    MainLogic.uiPackage.clearSpecialState();
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
            case Constant.GAME_UI_FRIEND_LIST:
                if (c == this.cmdOk) {
                    String inputValue = commonInput.getString().trim();
                    switch (this.byUiState) {
                        case 1://添加好友
                            if (inputValue.length() < 3 || inputValue.length() > 100) {
                                alert = new Alert("提示", "名称长度不正确（" + String.valueOf(Constant.MIN_ROLE_NAME_LENGTH) + "到" + String.valueOf(Constant.MAX_ROLE_NAME_LENGTH) + "个字符)!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                GameBean.BY_CMD_FRIEND_TYPE = 1;
                            }
                            break;
                        case 2://添加黑名单
                            if (inputValue.length() < 3 || inputValue.length() > 100) {
                                alert = new Alert("提示", "名称长度不正确（" + String.valueOf(Constant.MIN_ROLE_NAME_LENGTH) + "到" + String.valueOf(Constant.MAX_ROLE_NAME_LENGTH) + "个字符)!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                GameBean.BY_CMD_FRIEND_TYPE = 2;
                            }
                            break;
                        case 3://添加仇人
                            if (inputValue.length() < 3 || inputValue.length() > 100) {
                                alert = new Alert("提示", "名称长度不正确（" + String.valueOf(Constant.MIN_ROLE_NAME_LENGTH) + "到" + String.valueOf(Constant.MAX_ROLE_NAME_LENGTH) + "个字符)!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                GameBean.BY_CMD_FRIEND_TYPE = 3;
                            }
                            break;
                    }
                    GameBean.BY_CMD_FRIEND_NAME = inputValue;
                    if (GameBean.b_WAIT_NET_MSG_BACK) {
                        return;
                    }
                    GameBean.BY_CMD_FRIEND_MODE = 1;
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_ADD_FRIEND, Constant.SOCKET_MSG_TYPE_LOGIC);
                    GameBean.b_WAIT_NET_MSG_BACK = true;
                    MainGame.changeCanvas(MainGame.mainFrame);
                } else if (c == this.cmdCancel) {
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
            case Constant.GAME_UI_TRADE:
                if (c == this.cmdOk) {
                    long lCoppor = 0;
                    String inputValue = this.commonInput2.getString().trim();
                    if (!Tools.isNumeric(inputValue)) {
                        alert = new Alert("提示", "您输入的金币数量不正确!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        lCoppor = Integer.parseInt(inputValue) * 10000;
                        inputValue = this.commonInput3.getString().trim();
                        if (!Tools.isNumeric(inputValue)) {
                            alert = new Alert("提示", "您输入的银币数量不正确!", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else if (Integer.parseInt(inputValue) > 99) {
                            alert = new Alert("提示", "银币数量不能大于99!", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else {
                            lCoppor += Integer.parseInt(inputValue) * 100;
                            inputValue = this.commonInput4.getString().trim();
                            if (!Tools.isNumeric(inputValue)) {
                                alert = new Alert("提示", "您输入的铜币数量不正确!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else if (Integer.parseInt(inputValue) > 99) {
                                alert = new Alert("提示", "铜币数量不能大于99!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                lCoppor += Integer.parseInt(inputValue);
                                if (lCoppor > MainLogic.getInstance().uiInterFace.store.lPlayerMoney) {
                                    alert = new Alert("提示", "您输入的龙币数量大于您永远的龙币数量!", null, AlertType.INFO);
                                    MainGame.changeCanvas(alert);
                                } else {
                                    if (MainLogic.getInstance().uiInterFace.store.lMoney != lCoppor) {
                                        GameBean.b_WAIT_NET_MSG_BACK = true;
                                        GameBean.I_MONEY = (int) lCoppor;
                                        GameBean.L_PLAYER_ID = MainLogic.getInstance().uiInterFace.store.lTraderID;
                                        GameBean.BY_TYPE = 2;//(1,同步物品，2，同步金钱)
                                        GameBean.L_CMD_GOODS_SLOTKEY = 0;
                                        GameBean.BY_OP_TYPE = 1;//(1,添加物品，2，删除物品)
                                        MainGame.changeCanvas(MainGame.mainFrame);
                                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_SYNC_TRADE_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);
                                    } else {
                                        MainGame.changeCanvas(MainGame.mainFrame);
                                    }
                                }
                            }
                        }
                    }
                } else if (c == this.cmdCancel) {
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
            case Constant.GAME_UI_PET_EQUIP:
                if (c == this.cmdOk) {
                    String inputValue = this.commonInput.getString().trim();
                    byte code = Tools.checkStringLegal(inputValue, 1, 8);
                    if (code == 0) {
                        GameBean.STR_CMD_GOODS_NAME = inputValue;
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        //MainLogic.getInstance().uiInterFace.pet.bLockChangePetAlias = true;
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_PET_CHANGE_ALIAS, Constant.SOCKET_MSG_TYPE_LOGIC);
                        MainGame.changeCanvas(MainGame.mainFrame);
                    } else if (code == 1) {
                        alert = new Alert("提示", "您输入的宠物名称长度不正确(1到8个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (code == 2) {
                        alert = new Alert("提示", "您输入的宠物名称中有不合法的字符，请重新输入!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    }
                } else if (c == this.cmdCancel) {
                    MainLogic.getInstance().uiInterFace.pet.byUiState = 0;
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
            case Constant.GAME_UI_SET:
                switch (byUiState) {
                    case 1://密码修改
                        if (c == cmdOk) {
                            inputValue1 = commonInput.getString().trim();
                            inputValue2 = commonInput2.getString().trim();
                            inputValue3 = commonInput3.getString().trim();
                            if (inputValue1.length() < Constant.MIN_USER_NAME_LENGTH
                                    || inputValue1.length() > Constant.MAX_USER_NAME_LENGTH) {
                                alert = new Alert("提示", "用户名长度不正确(" + String.valueOf(Constant.MIN_USER_NAME_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_NAME_LENGTH) + "个字符)!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else if (inputValue2.length() < Constant.MIN_USER_PASSWORD_LENGTH || inputValue2.length() > Constant.MAX_USER_PASSWORD_LENGTH) {
                                alert = new Alert("提示", "您输入的旧密码的长度不正确(" + String.valueOf(Constant.MIN_USER_PASSWORD_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_PASSWORD_LENGTH) + "个字符)!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else if (inputValue3.length() < Constant.MIN_USER_PASSWORD_LENGTH || inputValue3.length() > Constant.MAX_USER_PASSWORD_LENGTH) {
                                alert = new Alert("提示", "新密码名长度不正确(" + String.valueOf(Constant.MIN_USER_PASSWORD_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_PASSWORD_LENGTH) + "个字符)!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else if (!Tools.isNumOrletters(inputValue1) || !Tools.isNumOrletters(inputValue2)
                                    || !Tools.isNumOrletters(inputValue3)) {
                                alert = new Alert("提示", "不支持中文，各种符号。", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {//发送修改密码指令
                                GameBean.STR_CMD_LOGIN_USENAME = inputValue1;
                                GameBean.STR_CMD_OLD_PASSWD = inputValue2;
                                GameBean.STR_CMD_NEW_PASSWD = inputValue3;
                                GameBean.BY_OP_TYPE = (byte) (choiceGroupOne.getSelectedIndex() + 1);
                                MainLogic.getInstance().uiLogin.byUiState = 0;
                                MainGame.changeCanvas(MainGame.mainFrame);
                                LocalMsgManager.getInstance().httpConnect(Constant.MSG_LOCAL_HTTP_CHANGE_PASSWORD);
                            }
                        } else if (c == cmdCancel) {
                            MainLogic.getInstance().uiLogin.byUiState = 0;
                            MainGame.changeCanvas(MainGame.mainFrame);
                        }
                        break;
                    case 2://联网设置
                        if (c == cmdOk) {
                            switch (choiceGroupOne.getSelectedIndex()) {
                                case 0://自动联网适配
                                    break;
                                case 1://CMWAP
                                    break;
                                case 2://CMNET
                                    break;
                                case 3://联通接入
                                    break;
                                case 4://互联网接入
                                    break;
                            }
                            MainLogic.getInstance().uiLogin.byUiState = 0;
                            MainGame.changeCanvas(MainGame.mainFrame);
                        } else if (c == cmdCancel) {
                            MainLogic.getInstance().uiLogin.byUiState = 0;
                            MainGame.changeCanvas(MainGame.mainFrame);
                        }
                        break;
                }
                break;
            case Constant.GAME_UI_STORE_BUY:
            case Constant.GAME_UI_WAGE_STORE:
            case Constant.GAME_UI_INGOT_RECORD:
            case Constant.GAME_UI_INGOT_STORE:
                if (c == this.cmdOk) {
                    if (Tools.isNumeric(commonInput.getString().trim())) {
                        int inputValue = Integer.parseInt(commonInput.getString().trim());
                        if (inputValue <= 0 || inputValue > 99) {
                            alert = new Alert("提示", "您输入的要购买的数量不正确(1到" + 99 + ")", null, AlertType.INFO);
                            MainGame.changeCanvas(alert);
                        } else {

                            switch (MainLogic.getInstance().byGameState) {
                                case Constant.GAME_UI_STORE_BUY:
                                    MainLogic.getInstance().uiInterFace.store.buyStoreGoods((byte) inputValue);
                                    break;
                                case Constant.GAME_UI_WAGE_STORE:
                                case Constant.GAME_UI_INGOT_RECORD:
                                case Constant.GAME_UI_INGOT_STORE:
                                    MainLogic.getInstance().uiInterFace.store.buyIngotStoreGoods((byte) inputValue);
                                    break;
                            }
                        }
                    } else {
                        alert = new Alert("提示", "您输入的不是数字!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    }
                } else if (c == this.cmdCancel) {
                    GameBean.b_WAIT_NET_MSG_BACK = false;
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
            case Constant.GAME_UI_PLAYER_STALL:
                switch (this.byUiState) {
                    case 0:
                    case 1:
                        if (c == this.cmdOk) {
                            long lCoppor = 0;
                            String inputValue = this.commonInput2.getString().trim();
                            if (!Tools.isNumeric(inputValue)) {
                                alert = new Alert("提示", "您输入的金币数量不正确!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            } else {
                                lCoppor = Integer.parseInt(inputValue) * 10000;
                                inputValue = this.commonInput3.getString().trim();
                                if (!Tools.isNumeric(inputValue)) {
                                    alert = new Alert("提示", "您输入的银币数量不正确!", null, AlertType.INFO);
                                    MainGame.changeCanvas(alert);
                                } else if (Integer.parseInt(inputValue) > 99) {
                                    alert = new Alert("提示", "银币数量不能大于99!", null, AlertType.INFO);
                                    MainGame.changeCanvas(alert);
                                } else {
                                    lCoppor += Integer.parseInt(inputValue) * 100;
                                    inputValue = this.commonInput4.getString().trim();
                                    if (!Tools.isNumeric(inputValue)) {
                                        alert = new Alert("提示", "您输入的铜币数量不正确!", null, AlertType.INFO);
                                        MainGame.changeCanvas(alert);
                                    } else if (Integer.parseInt(inputValue) > 99) {
                                        alert = new Alert("提示", "铜币数量不能大于99!", null, AlertType.INFO);
                                        MainGame.changeCanvas(alert);
                                    } else {
                                        lCoppor += Integer.parseInt(inputValue);
//                                            if (this.byUiState == 1) {
//                                                MainLogic.getInstance().uiInterFace.store.items.iPrice[ MainLogic.getInstance().uiInterFace.store.shPos] = (int) lCoppor;
//                                                MainLogic.getInstance().uiInterFace.store.sGoodsPrice = "售价：" + Tools.moneyConvert(lCoppor) + "/个";
//                                            } else {
//                                            }
                                        GameBean.I_MONEY = (int) lCoppor;
                                        MainGame.changeCanvas(MainGame.mainFrame);
                                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_OPT, Constant.SOCKET_MSG_TYPE_LOGIC);
                                    }
                                }
                            }
                        } else if (c == this.cmdCancel) {
                            MainLogic.getInstance().uiInterFace.store.byUiState = 0;
                            MainGame.changeCanvas(MainGame.mainFrame);
                        }
                        break;
                    case 2:
                        if (c == this.cmdOk) {
                            if (Tools.isNumeric(commonInput.getString().trim())) {
                                int inputValue = Integer.parseInt(commonInput.getString().trim());
                                int max = MainLogic.getInstance().uiInterFace.store.items.getGoodsStackNum(MainLogic.getInstance().uiInterFace.store.shPos);
                                if (inputValue <= 0 || inputValue > max) {
                                    alert = new Alert("提示", "您输入的要购买的数量不正确(1到" + max + ")", null, AlertType.INFO);
                                    MainGame.changeCanvas(alert);
                                } else {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    GameBean.BY_GOODS_NUM = (byte) inputValue;
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_BUY, Constant.SOCKET_MSG_TYPE_LOGIC);
                                    MainLogic.getInstance().uiInterFace.store.byUiState = 0;
                                    MainGame.changeCanvas(MainGame.mainFrame);
                                }
                            } else {
                                alert = new Alert("提示", "您输入的不是数字!", null, AlertType.INFO);
                                MainGame.changeCanvas(alert);
                            }
                        } else if (c == this.cmdCancel) {
                            GameBean.b_WAIT_NET_MSG_BACK = false;
                            MainLogic.getInstance().uiInterFace.store.byUiState = 0;
                            MainGame.changeCanvas(MainGame.mainFrame);
                        }
                        break;
                }
                break;
            case Constant.GAME_UI_HANGUP:
                if (c == cmdOk) {
                    if (Tools.isNumeric(commonInput.getString().trim())) {
                        MainLogic.getInstance().uiInterFace.property.iData[1] = Integer.parseInt(commonInput.getString().trim());
                        MainLogic.getInstance().uiInterFace.property.setExp();
                        MainGame.changeCanvas(MainGame.mainFrame);
                    } else {
                        alert = new Alert("提示", "您输入的不是数字!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    }
                } else if (c == cmdCancel) {
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
            case Constant.GAME_UI_CHANGE_PASSWD:
                if (c == cmdOk) {
                    inputValue1 = commonInput.getString().trim();
                    inputValue2 = commonInput2.getString().trim();
                    if (inputValue1.length() < Constant.MIN_USER_PASSWORD_LENGTH || inputValue1.length() > Constant.MAX_USER_PASSWORD_LENGTH) {
                        alert = new Alert("提示", "您输入的新登陆密码长度不正确(" + String.valueOf(Constant.MIN_USER_PASSWORD_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_PASSWORD_LENGTH) + "个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (inputValue2.length() < Constant.MIN_USER_PASSWORD_LENGTH || inputValue2.length() > Constant.MAX_USER_PASSWORD_LENGTH) {
                        alert = new Alert("提示", "您输入的二级密码长度不正确(" + String.valueOf(Constant.MIN_USER_PASSWORD_LENGTH) + "到" + String.valueOf(Constant.MAX_USER_PASSWORD_LENGTH) + "个字符)!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else if (!Tools.isNumOrletters(inputValue1) || !Tools.isNumOrletters(inputValue2)) {
                        alert = new Alert("提示", "密码只支持数字和英文字符。", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {//发送修改密码指令
                        GameBean.STR_CMD_OLD_PASSWD = GameBean.STR_CMD_SUPER_PASSWORD;
                        GameBean.STR_CMD_LOGIN_PASSWORD = inputValue1;
                        GameBean.STR_CMD_SUPER_PASSWORD = inputValue2;
                        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                        MainGame.changeCanvas(MainGame.mainFrame);
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHANGE_PASSWORD, Constant.SOCKET_MSG_TYPE_LOGIC);
                    }
                } else if (c == cmdCancel) {
                    MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
            case Constant.GAME_UI_CHARGE:
                if (c == this.cmdOk) {
                    GameBean.STR_CAHRGE_CARD_SN = this.commonInput.getString().trim();
                    GameBean.STR_CHARGE_CARD_PW = this.commonInput2.getString().trim();
                    if (GameBean.STR_CAHRGE_CARD_SN.length() < 8 || GameBean.STR_CHARGE_CARD_PW.length() < 8) {
                        alert = new Alert("提示", "您输入的充值卡号或是密码格式不正确!", null, AlertType.INFO);
                        MainGame.changeCanvas(alert);
                    } else {
                        GameBean.BY_OP_TYPE = MainLogic.getInstance().uiInterFace.gameSet.byChargeType;//充值卡得类型方式（1，神州府,2易宝，3，当了）
                        GameBean.BY_TYPE = MainLogic.getInstance().uiInterFace.gameSet.getCardRealType();//充值卡类型
                        GameBean.I_MONEY = MainLogic.getInstance().uiInterFace.gameSet.getCardMoney();//充值金额
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHARGE, Constant.SOCKET_MSG_TYPE_LOGIC);
                        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                        MainGame.changeCanvas(MainGame.mainFrame);
                    }
                } else if (c == this.cmdCancel) {
                    MainGame.changeCanvas(MainGame.mainFrame);
                }
                break;
        }
    }

    public void commandAction(Command c, Item item) {
        if (byGameState == Constant.GAME_UI_CHAT) {
            if (c == BUTTON_CMD) {
                GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                GameBean.BY_CMD_FRIEND_TYPE = 1;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FRIEND_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
                GameBean.b_WAIT_NET_MSG_BACK = true;
                MainGame.changeCanvas(MainGame.mainFrame);
            }
        }
        if (byGameState == Constant.GAME_UI_SEND_EMAIL) {
            if (c == BUTTON_CMD) {
                GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_SENDINPUT_EMAIL;
                GameBean.BY_CMD_FRIEND_TYPE = 1;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FRIEND_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
                MainGame.changeCanvas(MainGame.mainFrame);
            }
        }
    }
}
